#include<stdio.h>
#include<sys/wait.h>
#include<stdlib.h>
#include<unistd.h>
int main(){
	pid_t  rid=fork();
	if(rid==0){
		//子进程
		while(1){
			printf("我是子进程,pid:%d\n",getpid());
			sleep(1);	
		}
		printf("我是子进程，我要退出了\n");
		exit(123);
	}

	//父进程等待回收
	int code=0;
	pid_t id=waitpid(-1,&code,0);
	//显示退出的信息
	printf("父进程等待成功，子进程的退出信息，exit_code:%d,sig:%d\n",(code>>8)&0xFF,code&0x7F);
	return 0;
}
